<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="author" content="李愧愧">
    <title></title>
    <style>
        
    </style>
</head>
<body>
    
<script>
    // 找出一个数组中所有的偶数。
    var arr=[];
    var str=[];
    var length = prompt('请输入数组长度：');
    for(var i=0;i<length;i++){
       arr[i] = prompt('请输入第'+(i+1)+'个数：');
    }
    console.log(arr);
    function ouShu(arr){
        for(var j=0;j<length;j++){
            if(arr[j]%2==0){
                str+=arr[j]+' ';
            }
        }
        return str;
    }
    alert('偶数为:'+"\n"+ouShu(arr));
</script>
</body>
<ml>